package com.huitongjy.common.generator;


import com.huitongjy.common.zookeeper.ZooKeeperWorkId;

/**
 * 考试系统 主键Id生成器
 */
public class ExamKeyGenerator implements IKeyGenerator {
    private IKeyGenerator keyGenerator;

    public ExamKeyGenerator() {
        keyGenerator = new ExtraKeyGenerator(9, 12, ZooKeeperWorkId.getInstanse().getWorkerId(), 1L);
    }

    @Override
    public Long generateKey() {
        return keyGenerator.generateKey();
    }

    @Override
    public BatchKey generateKey(int num) {
        return keyGenerator.generateKey(num);
    }

    public static void main(String[] args) {
        ExamKeyGenerator generator = new ExamKeyGenerator();
        System.out.println(generator.generateKey());
        BatchKey batchKey = generator.generateKey(150);
        batchKey.forEachRemaining(System.out::println);
    }
}
